package com.bjsxt.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bjsxt.mapper.CoinMapper;
import com.bjsxt.domain.Coin;
import com.bjsxt.service.CoinService;
@Service
public class CoinServiceImpl extends ServiceImpl<CoinMapper, Coin> implements CoinService{

    @Override
    public Page<Coin> findByPage(String name, String type, Byte status, String title, String walletType, Page<Coin> page) {
        return page(page,new LambdaQueryWrapper<Coin>()
                .like(!StringUtils.isEmpty(name),Coin::getName,name)
                .like(!StringUtils.isEmpty(type),Coin::getType,type)
                .like(status!=null,Coin::getStatus,status)

                .like(!StringUtils.isEmpty(title),Coin::getTitle,title)

                .like(!StringUtils.isEmpty(walletType),Coin::getWallet,walletType)



        );
    }

    @Override
    public List<Coin> getCoinByStatus(Byte status) {
        return list(new LambdaQueryWrapper<Coin>().eq(Coin::getStatus,status));
    }








    /**
     * 使用货币的名称来查询货币
     * 货币的名称是唯一
     * @param coinName
     *
     * @return
     */
    @Override
    public Coin getCoinByCoinName(String coinName) {
        return getOne(new LambdaQueryWrapper<Coin>().eq(Coin::getName,coinName));
    }












}
